from Guanjianzi.Base import Base
import openpyxl,pytest
from selenium import webdriver

@pytest.fixture()
def driver():
    driver=webdriver.Firefox()
    driver.maximize_window()
    yield driver
    driver.quit()

def test_login(driver):
    #获取表格
    work=openpyxl.load_workbook('gjz.xlsx')
    #读取表格
    excel=work['Sheet1']
    #初始化驱动
    base=Base()
    #循环读取数据
    for row in excel.iter_rows(min_row=2,values_only=True):
        #读取关键字
        action=row[3]
        params={}
        #打开网址
        if action=='goto':
            params['url']=row[6]
        #定位元素
        elif action in ['send_keys','click','info']:
            params['loc']=[row[4],row[5]]
            print(row[4])
            print(row[5])

            if action == 'send_keys':
                params['info'] = row[6]

        method=getattr(base,str(action))
        method(**params)